*/
-#include "defs.h"
+#include "teletype.h"
+
+#include <cstdio> // for SEEK_CUR
+#include "defs.h" // for Waypoint, waypt_add
-#define MYNAME "teletype"
+#define MYNAME "teletype"
-static
-QVector<arglist_t> teletype_args = {
-};
/*******************************************************************************
* %%% global callbacks called by gpsbabel main process %%% *
*******************************************************************************/
-static uint32_t tty_wpt_count;
-static gbfile* fin;
-
-static void
-teletype_rd_init(const QString& fname)
+void
+TeletypeFormat::rd_init(const QString& fname)
{
char header[64];
tty_wpt_count = gbfgetint32(fin);
}
-static void
-teletype_rd_deinit()
+void
+TeletypeFormat::rd_deinit()
{
gbfclose(fin);
}
-static void
-teletype_read()
+void
+TeletypeFormat::read()
{
for (uint32_t i = 0; i < tty_wpt_count; i++) {
auto* wpt = new Waypoint;
waypt_add(wpt);
}
}
-
-/**************************************************************************/
-
-// capabilities below means: we can only read and write waypoints
-// please change this depending on your new module
-
-ff_vecs_t teletype_vecs = {
- ff_type_file,
- {
- (ff_cap)(ff_cap_read) /* waypoints */,
- ff_cap_none /* tracks */,
- ff_cap_none /* routes */
- },
- teletype_rd_init,
- nullptr,
- teletype_rd_deinit,
- nullptr,
- teletype_read,
- nullptr,
- nullptr,
- &teletype_args,
- CET_CHARSET_ASCII, 0 /* ascii is the expected character set */
- /* not fixed, can be changed through command line parameter */
- , NULL_POS_OPS,
- nullptr
-};
-/**************************************************************************/
--- /dev/null
+/*
+
+ teletype .way module
+
+ Copyright (C) 2002-2014 Robert Lipe, robertlipe+source@gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ */
+#ifndef TELETYPE_H_INCLUDED_
+#define TELETYPE_H_INCLUDED_
+
+#include <QString> // for QString
+#include <QVector> // for QVector
+
+#include <cstdint> // for uint32_t
+
+#include "defs.h" // for ff_cap, arglist_t, ff_cap_none, CET_CHARSET_ASCII, ff_cap_read, ff_type, ff_type_file
+#include "format.h" // for Format
+#include "gbfile.h" // for gbfile
+
+
+class TeletypeFormat : public Format
+{
+public:
+ QVector<arglist_t>* get_args() override
+ {
+ return &teletype_args;
+ }
+
+ ff_type get_type() const override
+ {
+ return ff_type_file;
+ }
+
+ QVector<ff_cap> get_cap() const override
+ {
+ /* waypoints, tracks, routes */
+ return {(ff_cap)(ff_cap_read), ff_cap_none, ff_cap_none};
+ }
+
+ QString get_encode() const override
+ {
+ return CET_CHARSET_ASCII;
+ }
+
+ int get_fixed_encode() const override
+ {
+ return 0;
+ }
+
+ void rd_init(const QString& fname) override;
+ void read() override;
+ void rd_deinit() override;
+
+private:
+ /* Data Members */
+
+ uint32_t tty_wpt_count{};
+ gbfile* fin{};
+
+ QVector<arglist_t> teletype_args = {
+ };
+
+};
+#endif // TELETYPE_H_INCLUDED_
#include "shape.h"
#include "skytraq.h"
#include "subrip.h"
+#include "teletype.h"
#include "unicsv.h"
#include "wintec_tes.h"
#include "xcsv.h"
extern ff_vecs_t mmo_vecs;
extern ff_vecs_t v900_vecs;
extern ff_vecs_t enigma_vecs;
-extern ff_vecs_t teletype_vecs;
extern ff_vecs_t format_garmin_xt_vecs;
extern ff_vecs_t mapbar_track_vecs;
extern ff_vecs_t f90g_track_vecs;
LegacyFormat v900_fmt {v900_vecs};
LegacyFormat enigma_fmt {enigma_vecs};
SkytraqFormat skytraq_fmt;
- LegacyFormat teletype_fmt {teletype_vecs};
+ TeletypeFormat teletype_fmt;
SkytraqfileFormat skytraq_ffmt;
MinihomerFormat miniHomer_fmt;
WintecTesFormat wintec_tes_fmt;